﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

using SQLExecute;

public partial class list_nghiphep : System.Web.UI.Page
{
    User u = new User();
    NghiPhep n = new NghiPhep();
    DataSet ds;
    string email;
    //double 
    protected void Page_Init(object sender, EventArgs e)
    {
       n.List_Nghi_Phep(gdNghiPhep, u.Email);
    }


    protected void Get_Nghi_Phep_Info(string email)
    {
        n = n.Get_Nghi_Phep_Info(email);
        if (n.PhepNam > 0)
            lPhepNam.Text = n.PhepNam.ToString()+ " ngày";
        else
            lPhepNam.Text = "0";

        if (n.PhepDacBiet > 0)
            lNghiDacBiet.Text = n.PhepDacBiet.ToString()+ " ngày";
        else
            lNghiDacBiet.Text = "0";

        if (n.NghiKhongHuongLuong > 0)
            lNghiKhongHuongLuong.Text = n.NghiKhongHuongLuong.ToString()+ " ngày";
        else
            lNghiKhongHuongLuong.Text = "0";

        if (n.NghiOm > 0)
            lNghiOm.Text = n.NghiOm.ToString()+ " ngày";
        else lNghiOm.Text = "0";



    }
        
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
            if (Session["email"] != null && Session["fullname"] != null)
            {
                u.Email = Session["email"].ToString();
                lFullName.Text = Session["fullname"].ToString();
                n.List_Nghi_Phep(gdNghiPhep,u.Email);
                //BindGrid();
                lUsername.Text = Session["username"].ToString();
                Get_Nghi_Phep_Info(u.Email);
            }
            else { Response.Redirect("login.aspx"); }
        else
             
             if (Session["email"] != null && Session["fullname"] != null)
            {
                u.Email = Session["email"].ToString();
                n.List_Nghi_Phep(gdNghiPhep, u.Email);
                Get_Nghi_Phep_Info(u.Email);
                }


    }
    protected void lnkLogout_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Response.Redirect("login.aspx");
    }
    
    protected void gdNghiPhep_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#f7f7f7';");
        if ((e.VisibleIndex % 2) == 0)
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
        }
        else
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white';");
        }
    }

}
